#include <iostream>
using namespace std;
#include "util/output.h"

#include "beast_http/http_client.h"

void readHandler(beast::error_code const &, const Http::StringResponse &resp)
{
    COUT << resp;
    COUT << resp.body();
}

int main()
{
    try {
        // auto client_ptr = std::make_shared<HttpsClient>("blog.csdn.net", 443);
        // Http::StringResponse resp;
        // client_ptr->get("/zww0815/article/details/51275266", resp);
        // COUT << resp.body() ;
        // auto async_client_ptr = std::make_shared<HttpsClient>("blog.csdn.net", 443);
        // async_client_ptr->async_get("/zww0815/article/details/51275266", readHandler);
        // async_client_ptr->run();
        auto unicom_client_ptr = std::make_shared<HttpsClient>("esim.wo.cn", 443);
        Http::HeadParam head_param;
        head_param["User-Agent"] = "gsma-rsp-lpad";
        head_param["X-Admin-Protocol"] = "gsma/rsp/v2.2.0";
        head_param["Content-Type"] = "application/json;charset=utf-8";
        Http::StringBody body = R"({
    "header":{
        "functionExecutionStatus":{
            "status":"Executed-Success"
        }
    },
    "euiccChallenge":"ZteSndlDlmA4VyLg7yEzMA==",
    "euiccInfo1":"v yA1ggMCAgCpFgQUfA5UcBQ+qJmO2d8wBXTJLlqayx+qFgQUfA5UcBQ+qJmO2d8wBXTJL lqayx8=",
    "smdpAddress":"esim.wo.cn"
})";
        Http::StringResponse resp;
        unicom_client_ptr->post("/gsma/rsp2/es9plus/initiateAuthentication", head_param, body, resp);
        COUT << resp;
        unicom_client_ptr->async_post("/gsma/rsp2/es9plus/initiateAuthentication", head_param, body, readHandler);
        unicom_client_ptr->run();
    }
    catch (std::exception &e) {
        CERR << e.what();
        throw;
    }
}
